readOrCreateAndValidate

fun <T : Config> readOrCreateAndValidate(configClass: () -> T): T

overload of readOrCreateAndValidate that automatically applies the name, folder, and subfolder from the config itself. Automatically adds ".toml" to the name for reading and writing.

Return

An instance of the configClass passed to it, updated and validated or passed back as-is, depending on circumstances and errors encountered

Author

fzzyhmstrs

Since

0.2.0

Parameters

T

type of config being created. Any subclass of Config

configClass

Function0 of T


overload of readOrCreateAndValidate that automatically applies the name, folder, and subfolder from the config itself. Automatically adds ".toml" to the name for reading and writing.

Return

An instance of the configClass passed to it, updated and validated or passed back as-is, depending on circumstances and errors encountered

Author

fzzyhmstrs

Since

0.3.2

Parameters

T

type of config being created. Any subclass of Config

configClass

Supplier of T


fun <T : Config> readOrCreateAndValidate(name: String, folder: String = "", subfolder: String = "", configClass: () -> T): T

Deprecated

Consider registerAndLoadConfig() instead, or readOrCreateAndValidate(configClass) for consistent application of names

Reads a config from File or Creates a new config class; writes out any corrections, updates, or new content to File. Automatically adds ".toml" to the name for reading and writing.

Includes Version updating support, automatic validation and correction, and detailed error reporting. Use this to generate the actual config class instance to be used in-game, if you have other custom initialization to perform, otherwise see registerAndLoadConfig. See the Example Config for typical usage case.

Return

An instance of the configClass passed to it, updated and validated or passed back as-is, depending on circumstances and errors encountered

Author

fzzyhmstrs

Since

0.2.0

Parameters

T

The config class type. Must be a subclass of Config

name

String. The config name, will become the file name. In an identifier, would be the "path". Adds ".toml" to the name for reading/writing to file automatically.

folder

String, optional. A base config folder name. If left out, will write to the main config directory (not recommended). In an Identifier, this would be the "namespace"

subfolder

String, optional. A subfolder name if desired. By default, blank. The file will appear in the base "namespace" folder if no child is given.

configClass

Function0. A provider of instances of the config class itself. In Kotlin this can typically be written like { MyConfigClass() }


fun <T : Config> readOrCreateAndValidate(name: String, folder: String = "", subfolder: String = "", configClass: Supplier<T>): T

Deprecated

Consider registerAndLoadConfig() instead, or readOrCreateAndValidate(configClass) for consistent application of names

Reads a config from File or Creates a new config class; writes out any corrections, updates, or new content to File. Automatically adds ".toml" to the name for reading and writing.

Includes Version updating support, automatic validation and correction, and detailed error reporting. Use this to generate the actual config class instance to be used in-game, if you have other custom initialization to perform, otherwise see registerAndLoadConfig. See the Example Config for typical usage case.

Return

An instance of the configClass passed to it, updated and validated or passed back as-is, depending on circumstances and errors encountered

Author

fzzyhmstrs

Since

0.3.2

Parameters

T

The config class type. Must be a subclass of Config

name

String. The config name, will become the file name. In an identifier, would be the "path". Adds ".toml" to the name for reading/writing to file automatically.

folder

String, optional. A base config folder name. If left out, will write to the main config directory (not recommended). In an Identifier, this would be the "namespace"

subfolder

String, optional. A subfolder name if desired. By default, blank. The file will appear in the base "namespace" folder if no child is given.

configClass

Supplier. A provider of instances of the config class itself.